Title: SQL W3S (By-BKK) / 025 Joins
Tags: Obsidian_to_Anki

Q: What does an SQL JOIN do?
A: It combines rows from two or more tables based on a related column

Q: True or False: The JOIN clause can only work with two tables at a time
A: False

Q: What column typically relates tables in an SQL JOIN?
A: A column that exists in both tables, often a primary/foreign key

Q: SQL JOIN is used to create a new table from existing tables. True/False
A: False

Q: What are the main types of SQL JOINs?
A: INNER JOIN, LEFT (OUTER) JOIN, RIGHT (OUTER) JOIN, FULL (OUTER) JOIN

Q: Which SQL JOIN returns only matching records in both tables?
A: INNER JOIN

Q: Example: How does INNER JOIN work?
A: It only returns rows that have matching values in both tables

Q: What does LEFT (OUTER) JOIN return?
A: All records from the left table and matched records from the right table

Q: What does RIGHT (OUTER) JOIN return?
A: All records from the right table and matched records from the left table

Q: What does FULL (OUTER) JOIN return?
A: All records where there is a match in either left or right table

Q: How is JOIN written in SQL?
A: Using the JOIN keyword with ON to specify matching columns

Q: Write an example of SQL INNER JOIN syntax
A: SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate FROM Orders INNER JOIN Customers ON Orders.CustomerID=Customers.CustomerID;

Q: What does ON do in a JOIN statement?
A: It specifies the column to match in the tables

Q: True or False: LEFT JOIN is also called LEFT OUTER JOIN
A: True

Q: True or False: JOIN always requires the ON clause to specify how tables are linked
A: True

Q: ON is used to match columns between tables. What keyword is used to join tables?
A: JOIN

Q: Example: SELECT Orders.OrderID, Customers.CustomerName FROM Orders INNER JOIN Customers ON Orders.CustomerID=Customers.CustomerID;
A: What does this example do? It shows how to link two tables using INNER JOIN

Q: Combine rows from two tables using a related column
A: What is the function of SQL JOIN?

Q: INNER JOIN returns records with matching values.
A: Which JOIN type is described?

Q: LEFT JOIN includes all rows from the left table, even if there's no match
A: Which JOIN type is described?

Q: RIGHT JOIN includes all rows from the right table, even if there's no match
A: Which JOIN type is described?

Q: FULL JOIN returns all rows from both tables, with matches where available
A: Which JOIN type is described?